package com.huishen.edrivenew.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;

import com.huishen.edrivenew.AppContext;
import com.huishen.edrivenew.R;
import com.huishen.edrivenew.bean.LessInfoBean;
import com.huishen.edrivenew.bean.LessonlistSchoolBean;
import com.huishen.edrivenew.bean.PointBean;

import java.util.ArrayList;
import java.util.List;

/**
 *
 */
public class DialogListApdater extends BaseAdapter {

    private Context mContext;
    private LayoutInflater mInflater = null;
    private List<PointBean> points;


    public DialogListApdater(Context ctx, List<PointBean> points ) {
        mContext = ctx;
        mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        
        this.points = points;
    }



    

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        GroupViewHolder group = null;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.dialog_list_item, null);
            group = new GroupViewHolder();
            group.number = (TextView) convertView.findViewById(R.id.number);
            group.value = (TextView) convertView.findViewById(R.id.value);
            group.detial = (TextView) convertView.findViewById(R.id.detial);
            convertView.setTag(group);
        } else {
            group = (GroupViewHolder) convertView.getTag();
        }
        
        // ----------------添加列表数据------------------
        PointBean bean = points.get(position);
        
        if(bean != null) {
            group.number.setText(position+1 + "");
            group.value.setText(bean.pointValue+"");
            group.detial.setText(bean.content);
        }
        
        return convertView;
    }



    private class GroupViewHolder {
        TextView number;
        TextView value;
        TextView detial;
    }





    @Override
    public int getCount() {
        if(points != null) {
            return points.size();
        }
        return 0;
    }



    @Override
    public Object getItem(int position) {
        return points.get(position);
    }


    @Override
    public long getItemId(int position) {
        return position;
    }


}
